package com.tbit.uqbike.center.util;

import cn.hutool.core.date.DateUtil;

import java.util.Date;

public class DateTimeUtil {

    /**
     * 获取当前时间
     */
    public static String getNowTime() {
        return DateUtil.now();
    }


    /**
     * 根据格林尼治时间格式化
     */
    public static String getDateTimeByGL(Long time) {
        return DateUtil.format(new Date(time), "yyyy-MM-dd HH:mm:ss");
    }

    /**
     * 获取两个时间差
     */
    public static int getTimeDF(String time1, String time2) {
        int time = (int) ((DateUtil.parse(time2).getTime() - DateUtil.parse(time1).getTime()) / 1000);
        return time;
    }

    public static void main(String[] args) {
        System.out.println(getNowTime());
        long time = System.currentTimeMillis();
        System.out.println(time);
        System.out.println(getDateTimeByGL(time));
        System.out.println(getTimeDF("2022-07-29 00:00:00", "2022-07-29 00:01:00"));
    }
}
